home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / library / help / tcl / control / case < prev    next >
Encoding:
Text File  |  1993-10-26  |  2.2 KB  |  43 lines  |  [TEXT/$Tcl]

  1.  
  2.           case string ?in? patList body ?patList body ...?
  3.           case string ?in? {patList body ?patList body ...?}
  4.  
  5.  
  6.      DESCRIPTION
  7.           Note: the case command is obsolete and is supported only for
  8.           backward  compatibility.  At some point in the future it may
  9.           be removed entirely.  You  should  use  the  switch  command
  10.           instead.
  11.  
  12.           The case command matches string against each of the  patList
  13.           arguments  in order.  Each patList argument is a list of one
  14.           or more patterns.  If any of these patterns  matches  string
  15.           then  case  evaluates the following body argument by passing
  16.           it recursively to the Tcl interpreter and returns the result
  17.           of  that  evaluation.   Each  patList argument consists of a
  18.           single pattern or list of patterns.  Each pattern  may  con-
  19.           tain any of the wild-cards described under string match.  If
  20.           a patList argument is default, the corresponding  body  will
  21.           be  evaluated  if  no patList matches string.  If no patList
  22.           argument matches string and no default is  given,  then  the
  23.           case command returns an empty string.
  24.  
  25.           Two syntaxes are provided for the  patList  and  body  argu-
  26.           ments.   The  first uses a separate argument for each of the
  27.           patterns and commands; this form is convenient if  substitu-
  28.           tions  are desired on some of the patterns or commands.  The
  29.           second form places all of the patterns and commands together
  30.           into  a  single argument; the argument must have proper list
  31.           structure, with the elements of the list being the  patterns
  32.           and  commands.   The  second form makes it easy to construct
  33.           multi-line case commands, since the braces around the  whole
  34.           list  make  it unnecessary to include a backslash at the end
  35.           of each line.  Since the patList arguments are in braces  in
  36.           the  second  form,  no command or variable substitutions are
  37.           performed on them;  this makes the behavior  of  the  second
  38.           form different than the first form in some cases.
  39.  
  40.  
  41.      KEYWORDS
  42.           case, match, regular expression
  43.